package com.jilefojing.session.service;

import java.util.List;
import java.util.Map;

import com.jilefojing.beans.enums.PlatformEnum;
import com.jilefojing.beans.enums.forusersession.StatusEnumForUserSession;
import com.jilefojing.beans.enums.forusersession.TypeEnumForUserSession;
import com.jilefojing.beans.exception.UserContextException;
import com.jilefojing.beans.pojos.UserSession;
import com.jilefojing.beans.pojos.enhanced.EnhancedUserSession;
import com.jilefojing.context.beans.vo.UserContext;
import com.jilefojing.context.beans.vo.UserToken;
import com.jilefojing.service.base.IBaseService;

/**
 * 
 * @author jgshun
 * 
 */
public interface IUserSessionService extends IBaseService<UserSession> {

	EnhancedUserSession generateEnhancedUserSession(long userId, TypeEnumForUserSession type, String deviceId, PlatformEnum platform, boolean isRM, Map<String, Object> extralParam)
			throws UserContextException;

	EnhancedUserSession save(UserSession userSession);

	UserContext loadSessionUserContext(UserToken userToken) throws UserContextException;

	EnhancedUserSession getEnhancedUserSessionByUid(String uid) throws UserContextException;

	void deleteByUid(String uid);

	void refreshSessionExpireByUid(String uid);

	UserContext addUserContextToSession(EnhancedUserSession enhancedUserSession);

	UserSession convetnEnhancedUserSessionToUserSession(EnhancedUserSession enhancedUserSession);

	List<EnhancedUserSession> getEnhancedUserSessionForUserByStatus(long userId, List<StatusEnumForUserSession> statuses);

	List<EnhancedUserSession> conventUserSessionsToEnhancedUserSessions(List<UserSession> userSessions);

	void updateStatusByUids(StatusEnumForUserSession offline, List<String> uids);

	void updateUserSessionStatusForOnlyOneOnline(EnhancedUserSession curEnhancedUserSession);

}
